\(\int \cot ^2(e+f x) (a+b \tan ^2(e+f x))^2 \, dx\) [208]

   Optimal result
   Rubi [A] (verified)
   Mathematica [C] (verified)
   Maple [A] (verified)
   Fricas [A] (verification not implemented)
   Sympy [B] (verification not implemented)
   Maxima [A] (verification not implemented)
   Giac [A] (verification not implemented)
   Mupad [B] (verification not implemented)

Optimal result

Integrand size = 23, antiderivative size = 38 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-(a-b)^2 x-\frac {a^2 \cot (e+f x)}{f}+\frac {b^2 \tan (e+f x)}{f} \]

[Out]

-(a-b)^2*x-a^2*cot(f*x+e)/f+b^2*tan(f*x+e)/f

Rubi [A] (verified)

Time = 0.07 (sec) , antiderivative size = 38, normalized size of antiderivative = 1.00, number of steps used = 4, number of rules used = 3, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.130, Rules used = {3751, 472, 209} \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-\frac {a^2 \cot (e+f x)}{f}-x (a-b)^2+\frac {b^2 \tan (e+f x)}{f} \]

[In]

Int[Cot[e + f*x]^2*(a + b*Tan[e + f*x]^2)^2,x]

[Out]

-((a - b)^2*x) - (a^2*Cot[e + f*x])/f + (b^2*Tan[e + f*x])/f

Rule 209

Int[((a_) + (b_.)*(x_)^2)^(-1), x_Symbol] :> Simp[(1/(Rt[a, 2]*Rt[b, 2]))*ArcTan[Rt[b, 2]*(x/Rt[a, 2])], x] /;
 FreeQ[{a, b}, x] && PosQ[a/b] && (GtQ[a, 0] || GtQ[b, 0])

Rule 472

Int[(((e_.)*(x_))^(m_.)*((a_) + (b_.)*(x_)^(n_))^(p_))/((c_) + (d_.)*(x_)^(n_)), x_Symbol] :> Int[ExpandIntegr
and[(e*x)^m*((a + b*x^n)^p/(c + d*x^n)), x], x] /; FreeQ[{a, b, c, d, e, m}, x] && NeQ[b*c - a*d, 0] && IGtQ[n
, 0] && IGtQ[p, 0] && (IntegerQ[m] || IGtQ[2*(m + 1), 0] ||  !RationalQ[m])

Rule 3751

Int[((d_.)*tan[(e_.) + (f_.)*(x_)])^(m_.)*((a_) + (b_.)*((c_.)*tan[(e_.) + (f_.)*(x_)])^(n_))^(p_.), x_Symbol]
 :> With[{ff = FreeFactors[Tan[e + f*x], x]}, Dist[c*(ff/f), Subst[Int[(d*ff*(x/c))^m*((a + b*(ff*x)^n)^p/(c^2
 + ff^2*x^2)), x], x, c*(Tan[e + f*x]/ff)], x]] /; FreeQ[{a, b, c, d, e, f, m, n, p}, x] && (IGtQ[p, 0] || EqQ
[n, 2] || EqQ[n, 4] || (IntegerQ[p] && RationalQ[n]))

Rubi steps \begin{align*} \text {integral}& = \frac {\text {Subst}\left (\int \frac {\left (a+b x^2\right )^2}{x^2 \left (1+x^2\right )} \, dx,x,\tan (e+f x)\right )}{f} \\ & = \frac {\text {Subst}\left (\int \left (b^2+\frac {a^2}{x^2}-\frac {(a-b)^2}{1+x^2}\right ) \, dx,x,\tan (e+f x)\right )}{f} \\ & = -\frac {a^2 \cot (e+f x)}{f}+\frac {b^2 \tan (e+f x)}{f}-\frac {(a-b)^2 \text {Subst}\left (\int \frac {1}{1+x^2} \, dx,x,\tan (e+f x)\right )}{f} \\ & = -(a-b)^2 x-\frac {a^2 \cot (e+f x)}{f}+\frac {b^2 \tan (e+f x)}{f} \\ \end{align*}

Mathematica [C] (verified)

Result contains higher order function than in optimal. Order 5 vs. order 3 in optimal.

Time = 0.11 (sec) , antiderivative size = 66, normalized size of antiderivative = 1.74 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=2 a b x-\frac {b^2 \arctan (\tan (e+f x))}{f}-\frac {a^2 \cot (e+f x) \operatorname {Hypergeometric2F1}\left (-\frac {1}{2},1,\frac {1}{2},-\tan ^2(e+f x)\right )}{f}+\frac {b^2 \tan (e+f x)}{f} \]

[In]

Integrate[Cot[e + f*x]^2*(a + b*Tan[e + f*x]^2)^2,x]

[Out]

2*a*b*x - (b^2*ArcTan[Tan[e + f*x]])/f - (a^2*Cot[e + f*x]*Hypergeometric2F1[-1/2, 1, 1/2, -Tan[e + f*x]^2])/f
 + (b^2*Tan[e + f*x])/f

Maple [A] (verified)

Time = 0.17 (sec) , antiderivative size = 38, normalized size of antiderivative = 1.00

method result size
parallelrisch \(\frac {-a^{2} \cot \left (f x +e \right )+b^{2} \tan \left (f x +e \right )-f x \left (a -b \right )^{2}}{f}\) \(38\)
derivativedivides \(\frac {b^{2} \left (\tan \left (f x +e \right )-f x -e \right )+2 a b \left (f x +e \right )+a^{2} \left (-\cot \left (f x +e \right )-f x -e \right )}{f}\) \(53\)
default \(\frac {b^{2} \left (\tan \left (f x +e \right )-f x -e \right )+2 a b \left (f x +e \right )+a^{2} \left (-\cot \left (f x +e \right )-f x -e \right )}{f}\) \(53\)
norman \(\frac {\frac {b^{2} \tan \left (f x +e \right )^{2}}{f}+\left (-a^{2}+2 a b -b^{2}\right ) x \tan \left (f x +e \right )-\frac {a^{2}}{f}}{\tan \left (f x +e \right )}\) \(57\)
risch \(-x \,a^{2}+2 x a b -x \,b^{2}-\frac {2 i \left (a^{2} {\mathrm e}^{2 i \left (f x +e \right )}-b^{2} {\mathrm e}^{2 i \left (f x +e \right )}+a^{2}+b^{2}\right )}{f \left ({\mathrm e}^{2 i \left (f x +e \right )}-1\right ) \left ({\mathrm e}^{2 i \left (f x +e \right )}+1\right )}\) \(85\)

[In]

int(cot(f*x+e)^2*(a+b*tan(f*x+e)^2)^2,x,method=_RETURNVERBOSE)

[Out]

(-a^2*cot(f*x+e)+b^2*tan(f*x+e)-f*x*(a-b)^2)/f

Fricas [A] (verification not implemented)

none

Time = 0.26 (sec) , antiderivative size = 50, normalized size of antiderivative = 1.32 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=-\frac {{\left (a^{2} - 2 \, a b + b^{2}\right )} f x \tan \left (f x + e\right ) - b^{2} \tan \left (f x + e\right )^{2} + a^{2}}{f \tan \left (f x + e\right )} \]

[In]

integrate(cot(f*x+e)^2*(a+b*tan(f*x+e)^2)^2,x, algorithm="fricas")

[Out]

-((a^2 - 2*a*b + b^2)*f*x*tan(f*x + e) - b^2*tan(f*x + e)^2 + a^2)/(f*tan(f*x + e))

Sympy [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 71 vs. \(2 (29) = 58\).

Time = 0.70 (sec) , antiderivative size = 71, normalized size of antiderivative = 1.87 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\begin {cases} \tilde {\infty } a^{2} x & \text {for}\: e = 0 \wedge f = 0 \\x \left (a + b \tan ^{2}{\left (e \right )}\right )^{2} \cot ^{2}{\left (e \right )} & \text {for}\: f = 0 \\\tilde {\infty } a^{2} x & \text {for}\: e = - f x \\- a^{2} x - \frac {a^{2}}{f \tan {\left (e + f x \right )}} + 2 a b x - b^{2} x + \frac {b^{2} \tan {\left (e + f x \right )}}{f} & \text {otherwise} \end {cases} \]

[In]

integrate(cot(f*x+e)**2*(a+b*tan(f*x+e)**2)**2,x)

[Out]

Piecewise((zoo*a**2*x, Eq(e, 0) & Eq(f, 0)), (x*(a + b*tan(e)**2)**2*cot(e)**2, Eq(f, 0)), (zoo*a**2*x, Eq(e,
-f*x)), (-a**2*x - a**2/(f*tan(e + f*x)) + 2*a*b*x - b**2*x + b**2*tan(e + f*x)/f, True))

Maxima [A] (verification not implemented)

none

Time = 0.31 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.21 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {b^{2} \tan \left (f x + e\right ) - {\left (a^{2} - 2 \, a b + b^{2}\right )} {\left (f x + e\right )} - \frac {a^{2}}{\tan \left (f x + e\right )}}{f} \]

[In]

integrate(cot(f*x+e)^2*(a+b*tan(f*x+e)^2)^2,x, algorithm="maxima")

[Out]

(b^2*tan(f*x + e) - (a^2 - 2*a*b + b^2)*(f*x + e) - a^2/tan(f*x + e))/f

Giac [A] (verification not implemented)

none

Time = 0.84 (sec) , antiderivative size = 46, normalized size of antiderivative = 1.21 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {b^{2} \tan \left (f x + e\right ) - {\left (a^{2} - 2 \, a b + b^{2}\right )} {\left (f x + e\right )} - \frac {a^{2}}{\tan \left (f x + e\right )}}{f} \]

[In]

integrate(cot(f*x+e)^2*(a+b*tan(f*x+e)^2)^2,x, algorithm="giac")

[Out]

(b^2*tan(f*x + e) - (a^2 - 2*a*b + b^2)*(f*x + e) - a^2/tan(f*x + e))/f

Mupad [B] (verification not implemented)

Time = 11.81 (sec) , antiderivative size = 70, normalized size of antiderivative = 1.84 \[ \int \cot ^2(e+f x) \left (a+b \tan ^2(e+f x)\right )^2 \, dx=\frac {b^2\,\mathrm {tan}\left (e+f\,x\right )}{f}-\frac {\mathrm {atan}\left (\frac {\mathrm {tan}\left (e+f\,x\right )\,{\left (a-b\right )}^2}{a^2-2\,a\,b+b^2}\right )\,{\left (a-b\right )}^2}{f}-\frac {a^2}{f\,\mathrm {tan}\left (e+f\,x\right )} \]

[In]

int(cot(e + f*x)^2*(a + b*tan(e + f*x)^2)^2,x)

[Out]

(b^2*tan(e + f*x))/f - (atan((tan(e + f*x)*(a - b)^2)/(a^2 - 2*a*b + b^2))*(a - b)^2)/f - a^2/(f*tan(e + f*x))